package test00.lx08;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author ZQX
 * @date 2025-04-09
 */
public class MainTest {
    public static void main(String[] args) {
        // 第一：定义数据源
        List<String> list01 = Arrays.asList("张三三", "李四四", "王五五", "赵六六", "田七", "王八");
        List<String> list02 = Arrays.asList("张学友", "张国荣", "张三丰", "张无忌", "张翠山", "王老五");

        // 第二：创建流对象
        Stream<String> stream01 = list01.stream();
        Stream<String> stream02 = list02.stream();

        // 第三：操作
        List<String> newList01 = stream01.filter(str -> str.length() == 3)
                .limit(3)
                .collect(Collectors.toList());

        Set<String> newList02 = stream02
                .filter(str -> str.startsWith("张"))
                .skip(2)
                .collect(HashSet::new, Set::add, Set::addAll);

        Stream
                .concat(newList01.stream(), newList02.stream())
                // R apply(T t);
                .map(Student::new)
                .forEach(System.out::println);


    }
}
